﻿using System.Windows.Data;
using System.Windows.Media.Imaging;
using System;
using System.Globalization;
using System.IO;

namespace Omnia.Converters
{
    public class BinaryToImageConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.SetSource(new MemoryStream(value as byte[]));
                return bitmap;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
